﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IM.Easy.GenServices.Dtos.Gen
{
    /// <summary>
    /// 代码生成文件信息
    /// </summary>
    public class CodeFileInfo
    {
        /// <summary>
        /// 文件名（含扩展名）
        /// </summary>
        public string FileName { get; set; }

        /// <summary>
        /// 文件相对路径（不含文件名）
        /// </summary>
        public string RelativePath { get; set; }
        /// 文件绝对路径（可选）
        /// </summary>
        public string? FullPath { get; set; }

        /// <summary>
        /// 文件内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 文件类型（如cs、html、js等）
        /// </summary>
        public string FileType { get; set; }

        /// <summary>
        /// 命名空间（可选）
        /// </summary>
        public string? Namespace { get; set; }

        /// <summary>
        /// 是否允许覆盖
        /// </summary>
        public bool Overwrite { get; set; } = false;

        /// <summary>
        /// 关联模板信息
        /// </summary>
        public Template Template { get; set; }

        /// <summary>
        /// 编程语言（如C#, JavaScript等）
        /// </summary>
        public string Language
        {
            get
            {
                if (string.IsNullOrWhiteSpace(FileName))
                    return "Unknown";

                var ext = Path.GetExtension(FileName).ToLowerInvariant();
                return ext switch
                {
                    ".cs" => "C#",
                    ".js" => "JavaScript",
                    ".ts" => "TypeScript",
                    ".java" => "Java",
                    ".py" => "Python",
                    ".cpp" => "C++",
                    ".c" => "C",
                    ".go" => "Go",
                    ".php" => "PHP",
                    ".rb" => "Ruby",
                    ".swift" => "Swift",
                    ".kt" => "Kotlin",
                    ".html" => "HTML",
                    ".css" => "CSS",
                    ".json" => "JSON",
                    ".xml" => "XML",
                    ".vue" => "Vue",
                    _ => "Unknown"
                };
            }
        }
    }
}
